import QtQuick 2.6
import Qt.labs.controls 1.0

Popup {
    id: toast

    property alias text: labelText.text

    modal: true
    focus: true
    y: contentArea.availableHeight / 2 - contentItem.height / 2
    x: contentArea.availableWidth / 2- contentItem.width / 2

    width: Math.min(contentArea.width, contentArea.height) / 3 * 2
    height: labelText.height + topPadding + bottomPadding


    closePolicy: Popup.OnEscape | Popup.OnPressOutside
    background: Rectangle {
        color: "black"
        radius: 6
    }

    Label {
        id: labelText
        width: toast.availableWidth

        horizontalAlignment: Text.AlignHCenter
        verticalAlignment: Text.AlignVCenter
        wrapMode: Text.WordWrap
        text: textMetrics.text

        font.pixelSize: 15
        color: "whitesmoke"
        lineHeight: 1.5
    }

    Timer {
        interval: 2000
        running: true
        repeat: false
        onTriggered: toast.close()
    }

}


